package org.thought;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.TextView;

public class Display extends Activity implements OnClickListener {
	Button close;
	TextView text;
	
	final int PRAYER = 1000;
	final int SAYING = 1001;
	
	public void onCreate(Bundle savedInstanceState){
		String[] elements;
		Intent intent;
		/*what we'll be writing*/
		int typeOfText;
		/*the index of the prayer/saying*/
		int index;
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.display);
		getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
		
		close = (Button)findViewById(R.id.close);
		text = (TextView)findViewById(R.id.text);
		
		intent = getIntent();
		typeOfText = intent.getIntExtra("text", PRAYER);
		
		elements = (typeOfText == PRAYER) 
				? getResources().getStringArray(R.array.prayers)
				: getResources().getStringArray(R.array.sayings);
		
		index = IndexGenerator.day(elements.length);
				
		text.setText(elements[index]);
		
		close.setOnClickListener(this);
	}
	
	@Override
	public void onClick(View v) {
		finish();
	}


}
